<template>
    <div class="reportFormPage" v-if="show">
        <div class="report-dom">
            <el-row>
                <el-col :span="5" :offset="19">
                    <div class="pageNumBox">
                        <span>第</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
                        <span>页，共</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
                        <span>页</span>
                    </div>
                </el-col>
            </el-row>
            <div class="topTwoBox">
                <div class="centerName">{{ this.form.baobmc }}</div>
                <div class="codeText">
                    <tr v-for="(item, index) in form.baobbhList">{{ item }}</tr>
                </div>
            </div>
            <div class="threeTopBox">
                <div class="left-border">
                    <div class="box-title">检测单位名称：</div>
                    <div class>{{ form.jiancdwmc }}</div>
                </div>
                <div class="right-border">
                    <span>记录编号：</span>
                    <span class="placeholder">{{ form.jilbh }}</span>
                </div>
            </div>
            <!-- .........................1111111111111111111111111111111......................................................... -->
            <div class="table-border">
                <table height="220px" class="top-table">
                    <tbody>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程名称</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcmc }}</span>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程部位/用途</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcbwyt }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center">样品信息</td>
                        <td class="specimen-border" colspan="3">
                            <span>样品名称：</span>
                            <span :class="{ 'placeholder': !form.yangpmc }">{{ form.yangpmc }}</span>
                            <span>；样品编号：</span>
                            <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                            <span>；样品数量：</span>
                            <span :class="{ 'placeholder': !form.yangpsl }">{{ form.yangpsl }}</span>
                            <span>；样品状态：</span>
                            <span :class="{ 'placeholder': !form.yangpzt }">{{ form.yangpzt }}</span>
                            <span>；来样时间：</span>
                            <span :class="{ 'placeholder': !form.yangpsj }">{{ form.yangpsj }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验检测日期</span>
                        </td>
                         <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
                        <td align="center" width="15%">
                            <span style="width:90px;display:inline-block">试验条件</span>
                        </td>
                        <td v-if="isPdf" width="35%">
                            温度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjwd }}</span>
                            ℃；湿度：
                            <span style="display: inline-block; width: 10%;">{{ form.shiytjsd }}</span>%RH
                        </td>
                        <td v-else width="35%">
                            温度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" class="height100"
                                      style="width: 15%"/>
                            ℃；湿度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" class="height100"
                                      style="width: 15%"/>
                            %RH
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">检测依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.jiancyj }}</span>
                            <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark"
                                      @dblclick.native="showBsJiancyjView" readonly/>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">判定依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.pandyj }}</span>
                            <el-input v-else type="textarea" v-model="form.pandyj" :rows="2"
                                      @dblclick.native="showBsJudgeBaseView"
                                      @focus="handleFocus('pandyj')" class="mark"/>
                        </td>
                    </tr>
                    <tr class="bottom-border">
                        <td height="50" align="center">
                            <div>主要仪器设备</div>
                            <div>名称及编号</div>
                        </td>
                        <td colspan="3">
                            <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh"
                                      class="height100 width100 mark"
                                      @dblclick.native="showBsInstrumentView" readonly></el-input>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .................................22222222222222222222222222222222............................................... -->
                <table height="516px" class="middle-table">
                    <tbody>
                    <tr>
                        <td colspan="8" width="100%">含泥量试验</td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">试验次数</td>
                        <td width="23%" colspan="2">试验前烘干试样质量m<sub>0</sub>(g)</td>
                        <td width="23%" colspan="2">试验后烘干试样质量m<sub>1</sub>(g)</td>
                        <td width="23%" colspan="1">含泥量测值(%)</td>
                        <td width="23%" colspan="2">含泥量测定值(%)</td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.hannlSycs1"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.hannlM11"
                                      @change="calculateHannlCz(1)"
                                      @keydown.native="handleKeyDown($event, 0, 0)"
                                      @paste.native="handlePaste($event, 0, 0)"
                                      :ref="'0_0'"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.hannlM21"
                                      @change="calculateHannlCz(1)"
                                      @keydown.native="handleKeyDown($event, 0, 1)"
                                      @paste.native="handlePaste($event, 0, 1)"
                                      :ref="'0_1'"/>
                        </td>
                        <td width="23%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.hannlCz1"
                                      disabled/>
                        </td>
                        <td width="23%" colspan="2" rowspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.hannlPjz"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.hannlSycs2"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.hannlM12"
                                      @change="calculateHannlCz(2)"
                                      @keydown.native="handleKeyDown($event, 1, 0)"
                                      @paste.native="handlePaste($event, 1, 0)"
                                      :ref="'1_0'"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.hannlM22"
                                      @change="calculateHannlCz(2)"
                                      @keydown.native="handleKeyDown($event, 1, 1)"
                                      @paste.native="handlePaste($event, 1, 1)"
                                      :ref="'1_1'"/>
                        </td>
                        <td width="23%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.hannlCz2"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="8" width="100%">泥块含量试验</td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">试验次数</td>
                        <td width="23%" colspan="2">试验前存留1.18mm筛上烘干试样质量 m<sub>1</sub> (g)</td>
                        <td width="23%" colspan="2">试验前存留1.18mm筛上烘干试样质量 m<sub>2</sub> (g)</td>
                        <td width="23%" colspan="1">泥块含量测值(%)</td>
                        <td width="23%" colspan="2">泥块含量测定值(%)</td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.nikhlSycs1"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.nikhlM01"
                                      @change="calculateNikhlCz(1)"
                                      @keydown.native="handleKeyDown($event, 2, 0)"
                                      @paste.native="handlePaste($event, 2, 0)"
                                      :ref="'2_0'"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.nikhlM11"
                                      @change="calculateNikhlCz(1)"
                                      @keydown.native="handleKeyDown($event, 2, 1)"
                                      @paste.native="handlePaste($event, 2, 1)"
                                      :ref="'2_1'"/>
                        </td>
                        <td width="23%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.nikhlCz1"
                                      disabled/>
                        </td>
                        <td width="23%" colspan="2" rowspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.nikhlPjz"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.nikhlSycs2"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.nikhlM02"
                                      @change="calculateNikhlCz(2)"
                                      @keydown.native="handleKeyDown($event, 3, 0)"
                                      @paste.native="handlePaste($event, 3, 0)"
                                      :ref="'3_0'"/>
                        </td>
                        <td width="23%" colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.nikhlM12"
                                      @change="calculateNikhlCz(2)"
                                      @keydown.native="handleKeyDown($event, 3, 1)"
                                      @paste.native="handlePaste($event, 3, 1)"
                                      :ref="'3_1'"/>
                        </td>
                        <td width="23%" colspan="1">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.nikhlCz2"
                                      disabled/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="8" width="100%">坚固性试验</td>
                    </tr>
                    <tr>
                        <td width="8%" colspan="1">硫酸钠溶液配制时间</td>
                        <td colspan="1">
                            <el-input tabindex="200" v-model="form.jiangxPzsj"
                                      @keydown.native="handleKeyDown($event, 4, 0)"
                                      :ref="'4_0'"/>
                        </td>
                        <td colspan="1">溶液温度（℃）</td>
                        <td colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.jiangxWd"
                                      @keydown.native="handleKeyDown($event, 4, 1)" :ref="'4_1'"/>
                        </td>
                        <td colspan="1">溶液相对密度</td>
                        <td colspan="2">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200" v-model="form.jiangxXdmd"
                                      @keydown.native="handleKeyDown($event, 4, 2)" :ref="'4_2'"/>
                        </td>
                    </tr>
                    <tr>
                        <td width="12%" colspan="1" rowspan="2">公称粒级（mm）</td>
                        <td width="15%" colspan="1" rowspan="2">每一粒级试样试验前的烘干质量m<sub>i</sub>（g）</td>
                        <td width="30%" colspan="3">循环试验后，每一粒级筛余颗粒烘干质量m'<sub>i</sub>（g）</td>
                        <td width="10%" colspan="1" rowspan="2">不同粒级的分计质量损失百分率（%）</td>
                        <td width="10%" colspan="1" rowspan="2">不同粒级的颗粒在原试样总量中的分计质量m<sub>i</sub>(g)
                        </td>
                        <td width="10%" colspan="1" rowspan="2">试样的坚固性损失百分率（%）</td>
                    </tr>
                    <tr>
                        <td width="10%" colspan="1">第一次称量</td>
                        <td width="10%" colspan="1">第二次称量</td>
                        <td width="10%" colspan="1">第三次称量</td>
                    </tr>
                    <tr>
                        <td width="12%">
                            <el-input v-model="form.jiangxGclj1"/>
                        </td>
                        <td rowspan="4">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxMi1"
                                      @keydown.native="handleKeyDown($event, 5, 0)"
                                      :ref="'5_0'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC11"
                                      @keydown.native="handleKeyDown($event, 5, 1)"
                                      @paste.native="handlePasteTwo($event, 0, 0)"
                                      :ref="'5_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC21"
                                      @keydown.native="handleKeyDown($event, 5, 2)"
                                      @paste.native="handlePasteTwo($event, 0, 1)"
                                      :ref="'5_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC31"
                                      @keydown.native="handleKeyDown($event, 5, 3)"
                                      @paste.native="handlePasteTwo($event, 0, 2)"
                                      :ref="'5_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxSsbfl1"
                                      @keydown.native="handleKeyDown($event, 5, 4)"
                                      @paste.native="handlePasteTwo($event, 0, 3)"
                                      :ref="'5_4'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxFjzl1"
                                      @keydown.native="handleKeyDown($event, 5, 5)"
                                      @paste.native="handlePasteTwo($event, 0, 4)"
                                      :ref="'5_5'"/>
                        </td>
                        <td rowspan="4">
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxPjz"
                                      @keydown.native="handleKeyDown($event, 5, 6)"
                                      :ref="'5_6'"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <el-input v-model="form.jiangxGclj2"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC12"
                                      @keydown.native="handleKeyDown($event, 6, 1)"
                                      @paste.native="handlePasteTwo($event, 1, 0)"
                                      :ref="'6_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC22"
                                      @keydown.native="handleKeyDown($event, 6, 2)"
                                      @paste.native="handlePasteTwo($event, 1, 1)"
                                      :ref="'6_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC32"
                                      @keydown.native="handleKeyDown($event, 6, 3)"
                                      @paste.native="handlePasteTwo($event, 1, 2)"
                                      :ref="'6_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxSsbfl2"
                                      @keydown.native="handleKeyDown($event, 6, 4)"
                                      @paste.native="handlePasteTwo($event, 1, 3)"
                                      :ref="'6_4'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxFjzl2"
                                      @keydown.native="handleKeyDown($event, 6, 5)"
                                      @paste.native="handlePasteTwo($event, 1, 4)"
                                      :ref="'6_5'"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <el-input v-model="form.jiangxGclj3"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC13"
                                      @keydown.native="handleKeyDown($event, 7, 1)"
                                      @paste.native="handlePasteTwo($event, 2, 0)"
                                      :ref="'7_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC23"
                                      @keydown.native="handleKeyDown($event, 7, 2)"
                                      @paste.native="handlePasteTwo($event, 2, 1)"
                                      :ref="'7_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC33"
                                      @keydown.native="handleKeyDown($event, 7, 3)"
                                      @paste.native="handlePasteTwo($event, 2, 2)"
                                      :ref="'7_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxSsbfl3"
                                      @keydown.native="handleKeyDown($event, 7, 4)"
                                      @paste.native="handlePasteTwo($event, 2, 3)"
                                      :ref="'7_4'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxFjzl3"
                                      @keydown.native="handleKeyDown($event, 7, 5)"
                                      @paste.native="handlePasteTwo($event, 2, 4)"
                                      :ref="'7_5'"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <el-input v-model="form.jiangxGclj4"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC14"
                                      @keydown.native="handleKeyDown($event, 8, 1)"
                                      @paste.native="handlePasteTwo($event, 3, 0)"
                                      :ref="'8_1'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC24"
                                      @keydown.native="handleKeyDown($event, 8, 2)"
                                      @paste.native="handlePasteTwo($event, 3, 1)"
                                      :ref="'8_2'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxC34"
                                      @keydown.native="handleKeyDown($event, 8, 3)"
                                      @paste.native="handlePasteTwo($event, 3, 2)"
                                      :ref="'8_3'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxSsbfl4"
                                      @keydown.native="handleKeyDown($event, 8, 4)"
                                      @paste.native="handlePasteTwo($event, 3, 3)"
                                      :ref="'8_4'"/>
                        </td>
                        <td>
                            <el-input :type="isPdf ? 'string' : 'number'" tabindex="200"
                                      v-model="form.jiangxFjzl4"
                                      @keydown.native="handleKeyDown($event, 8, 5)"
                                      @paste.native="handlePasteTwo($event, 3, 4)"
                                      :ref="'8_5'"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!-- .....................................................33333333333333333................................................... -->
                <table height="100px" class="bottom-table">
                    <tr>
                        <td>
                            <el-input type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')"/>
                        </td>
                    </tr>
                </table>
            </div>
            <!-- .................................44444444444............................................. -->
            <table height="22px" class="transparent">
                <tbody>
                <tr>
                    <td width="10%" align="right">检测：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jiancr}} -->
                    </td>
                    <td width="10%" align="right">记录：</td>
                    <td width="15%" align="left">
                        <!-- {{this.form.jilr}} -->
                    </td>
                    <td width="10%" align="right">复核：</td>
                    <td align="left" width="15%">
                        <!-- {{this.form.fuhr}} -->
                    </td>
                    <td width="10%">日期：</td>
                    <td align="left" width="15%">
                        <div style="display: inline-block; margin-right: 30px;">年</div>
                        <div style="display: inline-block; margin-right: 30px;">月</div>
                        <div style="display: inline-block;">日</div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
        <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
        <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    </div>
</template>

<script>
import {handleFocus, emptyConvert, calculateMeanvalue, handleKeyDown, handlePaste} from "@/views/reportForms/utils";
import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";
import {getXjlhnljlbBsInfo} from "@/api/report_jl/xjl";
import {computeBiQualification} from "@/api/sycs/biQualification";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

export default {
    name: "xjlhnljlb",
    components: {
        BsInstrumentView,
        BsJiancyjView,
        BsJudgeBaseView
    },
    props: {
        excelId: {
            type: [String, Number],
            default: () => ""
        },
        syType: {
            type: [String, Number],
            default: () => ""
        },
        page: {
            type: Number,
            default: () => 0
        },
        isPdf: {
            type: Boolean,
            default: () => false
        },
        printEmpty: {
            type: Boolean,
            default: () => false
        }
    },
    data() {
        return {
            form: {
                detailList: [],
                baobbhList: []
            },
            backBgz: {},
            show: false
        };
    },
    watch: {
        isPdf(newVal, oldVal) {
            this.form = {...emptyConvert(this.form, newVal)};
        },
        backBgz: {
            deep: true,
            immediate: true,
            handler(newVal, oldVal) {
                this.backBgzFun();
            }
        }
    },
    created() {
        this.init();
    },
    methods: {
        // 根据报表id获取当前报表信息
        init() {
            this.show = false;
            getXjlhnljlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
                this.form = response.data;
                this.setInitialValue();
                this.show = true;
                if (!this.form.fujsm) {
                    this.form.fujsm = "附加声明：";
                }
            });
        },
        // 设置初始值
        setInitialValue() {
            if (this.form) {
                this.form.baobmc = this.form.baobmc || "细集料含泥量、泥块含量、坚固性试验检测记录表";
                this.form.baobbh = this.form.baobbh || "JGLQ02017,JGLQ02018,JGLQ02019";
                this.$set(this.form, "baobbhList", []);
                this.form.baobbhList = ["JGLQ02017", "JGLQ02018", "JGLQ02019"];
                this.form.hannlSycs1 = "1";
                this.form.hannlSycs2 = "2";
                this.form.nikhlSycs1 = "1";
                this.form.nikhlSycs2 = "2";
                this.form.jiangxGclj1 = "0.3～0.6";
                this.form.jiangxGclj2 = "0.6～1.18";
                this.form.jiangxGclj3 = "1.18～2.36";
                this.form.jiangxGclj4 = "2.36～4.75";
            }
        },
        // 显示检测依据列表
        showBsJiancyjView() {
            this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
        },
        // 检测依据选择
        selectJiancyj(info) {
            this.form.jiancyj = info.label;
            this.form.jiancyjIds = info.ids;
            Bus.$emit("setXjlBgJiancyj", {jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds});
        },
        // 显示判定依据列表
        showBsJudgeBaseView() {
            this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
        },
        // 判断依据选择
        selectJudge(info) {
            if (!this.form.pandyj) {
                this.form.pandyj = info.label;
                return;
            }
            if (info && info.label) {
                this.form.pandyj += "、" + info.label;
            }
        },
        // 显示仪器列表
        showBsInstrumentView() {
            this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
        },
        // 仪器选择
        selectInstrument(info) {
            this.form.zhuyyqsbmcjbh = info.label;
            this.form.shebIds = info.ids;
            Bus.$emit("setXjlBgZhuyyqsbmcjbh", {zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds});
        },

        // 计算 含泥量测值
        calculateHannlCz(index) {
            // 100*(A-B)/A
            const A = this.form["hannlM1" + index];
            const B = this.form["hannlM2" + index];

            let num = null;
            if (A && B) {
                num = decimal.divide(decimal.multiply(100, decimal.subtract(A, B)), A, 2);
            }
            this.form["hannlCz" + index] = num;
            this.calculateHannlPjz();
        },
        // 计算平均值 - 含泥量
        calculateHannlPjz() {
            let arr = [];
            for (let i = 1; i <= 2; i++) {
                if (this.form["hannlCz" + i]) {
                    arr.push(this.form["hannlCz" + i]);
                }
            }
            this.form.hannlPjz = calculateMeanvalue(arr, 1);
            this.backBgzFun();
        },
        // 计算 泥块含量测值
        calculateNikhlCz(index) {
            // 100*(A-B)/A
            const A = this.form["nikhlM0" + index];
            const B = this.form["nikhlM1" + index];

            let num = null;
            if (A && B) {
                num = decimal.divide(decimal.multiply(100, decimal.subtract(A, B)), A, 2);
            }
            this.form["nikhlCz" + index] = num;
            this.calculateNikhlPjz();
        },
        // 计算平均值 - 泥块含量试验
        calculateNikhlPjz() {
            let arr = [];
            for (let i = 1; i <= 2; i++) {
                if (this.form["nikhlCz" + i]) {
                    arr.push(this.form["nikhlCz" + i]);
                }
            }
            this.form.nikhlPjz = calculateMeanvalue(arr, 1);
        },

        // 返回报告引入值
        backBgzFun() {
            Bus.$emit("setXjlBgJiancjg", [
                {key: 39, value: this.form.hannlPjz}, // 含泥量
                {key: 59, value: this.form.hannlPjz}, // 0.075mm以下粉尘含量
                {key: 61, value: this.form.hannlPjz} // 含泥量（小于0.075mm含量）（%）
            ]);
        },
        submitForm() {
            return this.form;
        },
        handleFocus(event) {
            handleFocus(event, this.page, this.form[event]);
        },
        handleKeyDown(event, rowIndex, colIndex) {
            const maxArr = [1, 1, 1, 1, 2, 6, 5, 5, 5]; // 每一行最多有多少可聚焦输入框（从0开始）
            const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
            const arr = ref.split("_");
            if ((arr[0] >= 6) && arr[1] == 0) {
                this.handleKeyDown(event, arr[0], arr[1]);
                return;
            }
            ;
            if (this.$refs[ref]) {
                this.$refs[ref].focus();
            }
        },
        // 粘贴赋值方法
        handlePaste(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["hannlM11", "hannlM21"],
                ["hannlM12", "hannlM22"],

                ["nikhlM01", "nikhlM11"],
                ["nikhlM02", "nikhlM12"],
            ];
            const subscriptArr = [
                [0, 1],
                [0, 1],

                [0, 1],
                [0, 1],
            ];

            const methodsAllArr = [
                ["calculateHannlCz", "calculateHannlCz"],
                ["calculateHannlCz", "calculateHannlCz"],

                ["calculateNikhlCz", "calculateNikhlCz"],
                ["calculateNikhlCz", "calculateNikhlCz"],
            ];
            const parameterArr = [
                [1, 1],
                [2, 2],

                [1, 1],
                [2, 2],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]) {
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 粘贴赋值方法
        handlePasteTwo(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["jiangxC11", "jiangxC21", "jiangxC31", "jiangxSsbfl1", "jiangxFjzl1"],
                ["jiangxC12", "jiangxC22", "jiangxC32", "jiangxSsbfl2", "jiangxFjzl2"],
                ["jiangxC13", "jiangxC23", "jiangxC33", "jiangxSsbfl3", "jiangxFjzl3"],
                ["jiangxC14", "jiangxC24", "jiangxC34", "jiangxSsbfl4", "jiangxFjzl4"],
            ];
            const subscriptArr = [
                [0, 1, 2, 3, 4],
                [0, 1, 2, 3, 4],
                [0, 1, 2, 3, 4],
                [0, 1, 2, 3, 4],
            ];

            const methodsAllArr = [];
            const parameterArr = [];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]) {
                        this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
                    }
                }
            }
        },

        // 计算方法调用
        setCalculate(name, a, b, c, d, e) {
            this[name](a, b, c, d, e);
        }
    }
};
</script>

<style scoped lang="scss"></style>
